using ExceptionHandlingDemo.Api.Infrastructures.Exceptions;
using Microsoft.AspNetCore.Mvc;

namespace ExceptionHandlingDemo.Api.Controllers;

[ApiController]
[Route("[controller]")]
public class OrderController : ControllerBase
{
    [HttpGet("{id}")]
    public int Get(int id)
    {
        if (id == 0)
        {
            throw new EntityNotFoundException(typeof(Order), id);
        }

        return id;
    }
}

public class Order
{
    public int Id { get; set; }
    public string Name { get; set; }
}